package com.powerbank.ordercenter.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.powerbank.ordercenter.entity.OrderLog;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 订单日志Mapper接口
 */
@Mapper
public interface OrderLogMapper extends BaseMapper<OrderLog> {

    /**
     * 根据订单ID查询订单日志
     */
    @Select("SELECT * FROM order_log WHERE order_id = #{orderId} ORDER BY created_time DESC")
    List<OrderLog> findByOrderId(@Param("orderId") Long orderId);

    /**
     * 根据订单号查询订单日志
     */
    @Select("SELECT * FROM order_log WHERE order_no = #{orderNo} ORDER BY created_time DESC")
    List<OrderLog> findByOrderNo(@Param("orderNo") String orderNo);

    /**
     * 根据操作类型查询订单日志
     */
    @Select("SELECT * FROM order_log WHERE operation_type = #{operationType} ORDER BY created_time DESC LIMIT #{limit}")
    List<OrderLog> findByOperationType(@Param("operationType") String operationType, @Param("limit") Integer limit);
}